package httpclient;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;


public class HttpGet {
	public static void main(String[] args) throws Exception{
		InetAddress inet = InetAddress.getByName("www.baidu.com");
		System.out.println(inet);
		Socket socket = new Socket("localhost",80);
		OutputStream os = socket.getOutputStream();
		os.write("GET / HTTP/1.1".getBytes());
		os.write("\r\n".getBytes());
		
		os.write("Host: www.baidu.com \r\n".getBytes());
		os.write("\r\n".getBytes());
		
		BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		String buffer;
		while((buffer = br.readLine()) != null) {
			System.out.println(buffer);
		}
		
		socket.close();
	}

}
